package com.gengzp.common.interceptor;

import com.gengzp.permission.utils.PermissionUtils;
import com.gengzp.rpc.interceptor.RpcHttpRequestInterceptor;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName RpcHttpRequestInterceptor
 * @Description rpc远程调用拦截器
 * @Author gengzp
 * @Date 2025/6/1 15:15
 */
@Component
public class RpcInterceptor implements RpcHttpRequestInterceptor {

    @Override
    public Map<String, Object> setHttpRequestHeaderBeforeRemoteCall() {
        Map<String, Object> headers = Maps.newHashMap();

        // 将当前用户的登录状态拼接到请求头中
        headers.put("Authorization", "Bearer " + PermissionUtils.getCurrentUserToken());

        return headers;
    }

}
